package cn.com.connext.scrm.web.rest;

import cn.com.connext.scrm.service.UserAccessRecordService;
import cn.com.connext.scrm.web.rest.vm.BrowseVM;
import com.codahale.metrics.annotation.Timed;
import com.connext.common.web.rest.BaseResource;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URISyntaxException;

/**
 * 2 * @Author: shawn
 * 3 * @Date: 2019/10/29 6:56 下午
 * 4
 */
@RestController
@RequestMapping("/api/access/")
public class UserAccessRecordResource extends BaseResource {
    public UserAccessRecordResource() {
        super("AccessRecord");
    }

    private static final Logger log = LoggerFactory.getLogger(UserAccessRecordResource.class);

    @Autowired
    private UserAccessRecordService userAccessRecordService;

    @PostMapping("browse")
    @ApiOperation(value = "添加浏览记录", tags = {"浏览"}, notes = "添加浏览记录")
    @Timed
    public ResponseEntity browse(@RequestBody BrowseVM vm) throws URISyntaxException {
        try{
            userAccessRecordService.browse(vm);
            return createSuccess("ok");
        }catch (Exception e){
            log.error("e:{}", e);
            return null;
        }
    }


}
